<?php
header("Content-Type:application/json;charset=utf-8");
//1.引用init.php
require("../init.php");
//2.接收从login.html传来的uname，upwd
@$uname = $_REQUEST["uname"];
@$upwd = $_REQUEST["upwd"];
//3.SQL语句
$sql = " SELECT uid FROM dk_user WHERE uname = '$uname' AND upwd = '$upwd' ";
$result = mysqli_query($conn, $sql);
if(mysqli_error($conn)){
    echo mysqli_error($conn);
}
//看是否抓取到一条记录
$row = mysqli_fetch_row($result);
if($row != null){
    $uid=$row[0];
    session_start();
    $_SESSION["uid"]=$uid;
    echo '{"code":1, "msg": "登录成功"}';
}else{
    echo '{"code":0 , "msg": "用户名或密码不正确！"}';
}
?>